<?php
$printTemplateArray = $this->adminHelper()->erpPrintTemplateState('stockTransfer');
if ($printTemplateArray['state']) echo $this->partial('admin/print-template/inCss');
?>
<div class="content-wrapper">
    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right" id="dberp-menu-top">
            <a href="<?php echo $this->url('stock-transfer');?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?php echo $this->translate('返回库间调拨列表'); ?></a>
            <button type="button" onclick="<?php echo $printTemplateArray['state'] ? 'directPrint()' : 'toPrint()'; ?>;" class="btn btn-primary btn-sm"><i class="fa fa-print" aria-hidden="true"></i> <?php echo $this->translate('点击打印'); ?></button>
            <?php echo $this->HelpUrl('stockTransfer'); ?>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-md-12" id="to-print-info">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title"><?php echo $this->translate('库间调拨详情'); ?></h3>
                    </div>

                    <div class="box-body">
                        <div class="row">
                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?php echo $this->translate('调拨单号'); ?>：</b><?php echo $this->escapeHtml($this->transferInfo->getTransferSn());?>
                                </div>
                            </div>

                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?php echo $this->translate('调出仓库'); ?>：</b><?php echo $this->escapeHtml($this->transferInfo->getOutOneWarehouse()->getWarehouseName());?>
                                </div>
                            </div>

                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?php echo $this->translate('调入仓库'); ?>：</b><?php echo $this->escapeHtml($this->transferInfo->getInOneWarehouse()->getWarehouseName());?>
                                </div>
                            </div>

                        </div>

                        <div class="row">
                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?php echo $this->translate('申请调拨时间'); ?>：</b><?php echo date("Y-m-d", $this->transferInfo->getTransferAddTime());?>
                                </div>
                            </div>
                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?php echo $this->translate('完成调拨时间'); ?>：</b><?php echo empty($this->transferInfo->getTransferFinishTime()) ? '' : date("Y-m-d", $this->transferInfo->getTransferFinishTime());?>
                                </div>
                            </div>
                            <div class="col-xs-4 form-group">
                                <div class="col-sm-12">
                                    <b><?php echo $this->translate('备注'); ?>：</b><?php echo $this->escapeHtml($this->transferInfo->getTransferInfo());?>
                                </div>
                            </div>
                        </div>

                        <div class="box-header">
                            <h4 class="box-title"><?php echo $this->translate('调拨商品'); ?></h4>
                        </div>
                        <div class="box-body table-responsive no-padding">
                            <table class="table table-hover">
                                <thead>
                                <tr>
                                    <th width="15%"><?php echo $this->translate('商品编号'); ?></th>
                                    <th width="20%"><?php echo $this->translate('商品名称'); ?></th>
                                    <th width="15%"><?php echo $this->translate('商品规格'); ?></th>
                                    <th width="5%"><?php echo $this->translate('单位'); ?></th>
                                    <th width="8%"><?php echo $this->translate('调拨数量'); ?></th>
                                    <th width="12%"><?php echo $this->translate('状态'); ?></th>
                                </tr>
                                </thead>
                                <?php foreach ($this->transferGoods as $goodsValue) { ?>
                                    <tr>
                                        <td><?php echo $this->escapeHtml($goodsValue->getGoodsNumber()); ?></td>
                                        <td>
                                            <?php echo $this->escapeHtml($goodsValue->getGoodsName()); ?>
                                            <?php if (!empty($goodsValue->getGoodsSerialNumberStr())) { ?>
                                                <span class="badge bg-green"><?php echo $this->translate('序列号'); ?></span>
                                            <?php } ?>
                                        </td>
                                        <td><?php echo $this->escapeHtml($goodsValue->getGoodsSpec()); ?></td>
                                        <td><?php echo $this->escapeHtml($goodsValue->getGoodsUnit()); ?></td>
                                        <td><?php echo $goodsValue->getTransferGoodsNum(); ?></td>
                                        <td><?php echo $this->stockHelper()->transferGoodsState($goodsValue->getTransferGoodsState(), 2); ?></td>
                                    </tr>
                                    <?php if (!empty($goodsValue->getGoodsSerialNumberStr())) { ?>
                                        <tr>
                                            <td colspan="6">
                                                <?php echo $this->escapeHtml($goodsValue->getGoodsName()); ?> <?php echo $this->translate('序列号：') . $goodsValue->getGoodsSerialNumberStr(); ?>
                                            </td>
                                        </tr>
                                    <?php } ?>
                                <?php } ?>
                            </table>
                        </div>

                    </div>

                </div>


            </div>
        </div>

    </section>

</div>
<?php
if ($printTemplateArray['state']) {
    echo $this->partial('admin/print-template/inJavascript', [
        'templateBody' => $printTemplateArray['templateBody'],
        'templateCode' => $printTemplateArray['templateCode'],
        'printData' => \Admin\Service\Common\PrintTemplate::stockTransfer([
            'transferInfo'  => $this->transferInfo,
            'transferGoods' => $this->transferGoods,
            'stockHelper'   => $this->stockHelper(),
            'basePath'      => rtrim($this->basePath('/'), '/')
        ], $printTemplateArray['templateBody'])]);
}
?>